#include "sdlthread.h"
#include <SDL.h>
#include <stdio.h>

SDLThread::SDLThread() {}

int SDLThread::preccessThread(void* data)
{
    int thread_id  = *(int*)data;

    printf("thread %d is running \n",thread_id);

    SDL_Delay(2000);

    printf("thread %d finished\n",thread_id);
    return 5;
}

void SDLThread::sdlThread()
{
    SDL_Init(SDL_INIT_VIDEO);

    int num = 555;

    SDL_Thread* thread = SDL_CreateThread(preccessThread,"thread 1",(void*)&num);

    int thread_res = 0;
    SDL_WaitThread(thread,&thread_res);

    printf("thread res is %d",thread_res);
    SDL_Quit();
}
